package cn.git.agent;

import org.apache.commons.lang3.StringUtils;

/**
 * @description: 插件定义类，git- plugins.def 文件中的对应关系
 * @program: bank-credit-sy
 * @author: lixuchun
 * @create: 2024-12-27
 */
public class PluginDefine {

    /**
     * 插件名称 eg: mysql5,springmvc 。。。。。
     */
    private String name;

    /**
     * The class name of plugin defined.
     */
    private String defineClass;

    private PluginDefine(String name, String defineClass) {
        this.name = name;
        this.defineClass = defineClass;
    }

    public static PluginDefine build(String define) {
        if (StringUtils.isEmpty(define)) {
            throw new RuntimeException(define);
        }

        String[] pluginDefine = define.split("=");
        if (pluginDefine.length != 2) {
            throw new RuntimeException(define);
        }

        String pluginName = pluginDefine[0];
        String defineClass = pluginDefine[1];
        return new PluginDefine(pluginName, defineClass);
    }

    public String getDefineClass() {
        return defineClass;
    }

    public String getName() {
        return name;
    }

}
